<?php
/**
 * Report
 *
 * PHP version 5
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */

/**
 * Amazon Ads API - Sponsored Products
 *
 * Use the Amazon Ads API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the [Sponsored Products Support Center](https://advertising.amazon.com/help?entityId=ENTITY3CWETCZD9HEG2#GWGFKPEWVWG2CLUJ). For onboarding information, see the [account setup](guides/onboarding/overview) topic.<br/> <br/> **Note**: This contract contains endpoints with upcoming planned deprecations. For more information on the latest versions and migration details, see [Deprecations](release-notes/deprecations).<br/> <br/>
 *
 * OpenAPI spec version: 2.0
 * 
 * Generated by:https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api.git
 * AmazonAdvertisingApi Codegen version: 3.0.51
 */
/**
 * NOTE: This class is auto generated by the AmazonAdvertisingApi code generator program.
 *https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 * Do not edit the class manually.
 */

namespace AmazonAdvertisingApi\Model;

use \ArrayAccess;
use \AmazonAdvertisingApi\ObjectSerializer;

/**
 * Report Class Doc Comment
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */
class Report implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $AmazonAdvertisingApiModelName = 'Report';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiTypes = [
        'state_filter' => 'string',
        'campaign_type' => 'string',
        'segment' => 'string',
        'report_date' => 'string',
        'metrics' => '\AmazonAdvertisingApi\Model\ReportMetrics'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiFormats = [
        'state_filter' => null,
        'campaign_type' => null,
        'segment' => null,
        'report_date' => null,
        'metrics' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiTypes()
    {
        return self::$AmazonAdvertisingApiTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiFormats()
    {
        return self::$AmazonAdvertisingApiFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'state_filter' => 'stateFilter',
        'campaign_type' => 'campaignType',
        'segment' => 'segment',
        'report_date' => 'reportDate',
        'metrics' => 'metrics'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'state_filter' => 'setStateFilter',
        'campaign_type' => 'setCampaignType',
        'segment' => 'setSegment',
        'report_date' => 'setReportDate',
        'metrics' => 'setMetrics'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'state_filter' => 'getStateFilter',
        'campaign_type' => 'getCampaignType',
        'segment' => 'getSegment',
        'report_date' => 'getReportDate',
        'metrics' => 'getMetrics'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$AmazonAdvertisingApiModelName;
    }

    const STATE_FILTER_ENABLED = 'enabled';
    const STATE_FILTER_PAUSED = 'paused';
    const STATE_FILTER_ARCHIVED = 'archived';
    const CAMPAIGN_TYPE_SPONSORED_PRODUCTS = 'sponsoredProducts';
    const SEGMENT_QUERY = 'query';
    const SEGMENT_PLACEMENT = 'placement';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getStateFilterAllowableValues()
    {
        return [
            self::STATE_FILTER_ENABLED,
            self::STATE_FILTER_PAUSED,
            self::STATE_FILTER_ARCHIVED,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getCampaignTypeAllowableValues()
    {
        return [
            self::CAMPAIGN_TYPE_SPONSORED_PRODUCTS,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getSegmentAllowableValues()
    {
        return [
            self::SEGMENT_QUERY,
            self::SEGMENT_PLACEMENT,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['state_filter'] = isset($data['state_filter']) ? $data['state_filter'] : null;
        $this->container['campaign_type'] = isset($data['campaign_type']) ? $data['campaign_type'] : null;
        $this->container['segment'] = isset($data['segment']) ? $data['segment'] : null;
        $this->container['report_date'] = isset($data['report_date']) ? $data['report_date'] : null;
        $this->container['metrics'] = isset($data['metrics']) ? $data['metrics'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getStateFilterAllowableValues();
        if (!is_null($this->container['state_filter']) && !in_array($this->container['state_filter'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'state_filter', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getCampaignTypeAllowableValues();
        if (!is_null($this->container['campaign_type']) && !in_array($this->container['campaign_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'campaign_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getSegmentAllowableValues();
        if (!is_null($this->container['segment']) && !in_array($this->container['segment'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'segment', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets state_filter
     *
     * @return string
     */
    public function getStateFilter()
    {
        return $this->container['state_filter'];
    }

    /**
     * Sets state_filter
     *
     * @param string $state_filter Filters the response to include reports with `stateFilter` set to one of the values in the comma-delimited list. `stateFilter` and `segment` cannot be used in the same report request.  `asins` report types do not support the use of `stateFilter`.
     *
     * @return $this
     */
    public function setStateFilter($state_filter)
    {
        $allowedValues = $this->getStateFilterAllowableValues();
        if (!is_null($state_filter) && !in_array($state_filter, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'state_filter', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['state_filter'] = $state_filter;

        return $this;
    }

    /**
     * Gets campaign_type
     *
     * @return string
     */
    public function getCampaignType()
    {
        return $this->container['campaign_type'];
    }

    /**
     * Sets campaign_type
     *
     * @param string $campaign_type The type of campaign. Only required for `asins` reports - don't use with other report types.
     *
     * @return $this
     */
    public function setCampaignType($campaign_type)
    {
        $allowedValues = $this->getCampaignTypeAllowableValues();
        if (!is_null($campaign_type) && !in_array($campaign_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'campaign_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['campaign_type'] = $campaign_type;

        return $this;
    }

    /**
     * Gets segment
     *
     * @return string
     */
    public function getSegment()
    {
        return $this->container['segment'];
    }

    /**
     * Sets segment
     *
     * @param string $segment A secondary dimension used to further segment certain types of reports. `stateFilter` and `segment` cannot be used in the same report request. Keyword search term reports only return search terms that have generated at least one click or sale.  **Note**: Search term reports for auto-targeted campaigns created before 11/14/2018 can be accessed from the `/v2/sp/keywords/report` resource. Search term reports for auto-targeted campaigns generated on-and-after 11/14/2018 can be accessed from the `/v2/sp/targets/report` resource.   | Dimension | Valid report types | Description | |-----------|-------------|-------------| | query | keywords, targets | Segments a report based on customer search term. | | placement | campaigns | Segments a `campaigns` report based on the page location where the ad appeared. |
     *
     * @return $this
     */
    public function setSegment($segment)
    {
        $allowedValues = $this->getSegmentAllowableValues();
        if (!is_null($segment) && !in_array($segment, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'segment', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['segment'] = $segment;

        return $this;
    }

    /**
     * Gets report_date
     *
     * @return string
     */
    public function getReportDate()
    {
        return $this->container['report_date'];
    }

    /**
     * Sets report_date
     *
     * @param string $report_date The date for which to retrieve the performance report in YYYYMMDD format. The time zone is specified by the profile used to request the report. If this date is today, then the performance report may contain partial information. Reports are not available for data older than 60 days. For details on data latency, see the service guarantees in the [developer notes](https://advertising.amazon.com/API/docs/en-us/reference/concepts/developer-notes) section.
     *
     * @return $this
     */
    public function setReportDate($report_date)
    {
        $this->container['report_date'] = $report_date;

        return $this;
    }

    /**
     * Gets metrics
     *
     * @return \AmazonAdvertisingApi\Model\ReportMetrics
     */
    public function getMetrics()
    {
        return $this->container['metrics'];
    }

    /**
     * Sets metrics
     *
     * @param \AmazonAdvertisingApi\Model\ReportMetrics $metrics metrics
     *
     * @return $this
     */
    public function setMetrics($metrics)
    {
        $this->container['metrics'] = $metrics;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
